package computer;

/**
 * @author 孤雪唯方
 * @date 2025/05/12
 * @description 电脑类，使用USB设备
 */
public class Computer {
    /**
     * 电脑上电，即开机
     */
    public void powerOn() {
        System.out.println("Computer is turned on.");
    }

    /**
     * 设备关机
     */
    public void powerOff() {
        System.out.println("Computer is turned off.");
    }

    /**
     * usb设备驱动
     *
     * @param usb usb
     */
    public void usbDevice(USB usb) {
        usb.connect();
        if (usb instanceof Mouse) {
            Mouse mouse = (Mouse) usb;
            mouse.click();
        } else if (usb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.inPut();
        }
        usb.disconnect();
    }
}
